/*
============================================================================
 Name        : dd_test.c
 Author      : Jian (raphyer@hotmail.com)
 Version     :
 Copyright   : GPL
 Description : dd_test.c - source file
============================================================================
*/

/* INCLUDE FILES */
#include "dd_test.h"
#include "pd_time.h"


#ifdef __DD_UNITTEST

static DD_UINT _start_sec  = 0 ;
static DD_UINT _start_usec = 0 ;

void dd_ut_time_start(const DD_CHAR* task_msg) 
{
    dd_time time ;
    pd_get_curtime(&time) ;

    _start_sec = time.second ;
    _start_usec = time.microsecond ;

    DD_LOG("===== Start to count %s =====", task_msg) ;
}

void dd_ut_time_end(const DD_CHAR* task_msg) 
{
    dd_time time ;
    pd_get_curtime(&time) ;

    if (time.microsecond >= _start_usec)
        DD_LOG("===== End to count %s diff second = %d and microsecond = %d =====", task_msg, time.second - _start_sec, time.microsecond - _start_usec) ;
    else 
        DD_LOG("===== End to count %s diff second = %d and microsecond = %d =====", task_msg, time.second - 1 - _start_sec, time.microsecond + 1000000 - _start_usec) ;

    _start_sec  = time.second ;
    _start_usec = time.microsecond ;
}


extern DD_BOOL dd_structure_test()  ;
extern DD_BOOL pd_file_test()  ;
extern DD_BOOL pd_unicode_test() ;


DD_BOOL dd_test() 
{
	DD_LOG("dd_test start the UNIT TEST") ;
    
    if (!pd_file_test()) {
        DD_LOG("pd_file_test test FAILED") ;
        return DD_FALSE ;            
    }

    if (!pd_unicode_test()) {
        DD_LOG("pd_unicode_test test FAILED") ;
        return DD_FALSE ;            
    }
    
    /*
    if (!dd_structure_test()) {
        DD_LOG("dd_structure_test test FAILED") ;
        return DD_FALSE ;            
    }
    */

	DD_LOG("dd_test the UNIT TEST is SUCCEED") ;

	return DD_TRUE ;
}


#else

void dd_ut_time_start(const DD_CHAR* task_msg) 
{
}

void dd_ut_time_end(const DD_CHAR* task_msg) 
{
}

DD_BOOL dd_test() 
{
	return DD_TRUE ;
}

#endif	/* __DD_UNITTEST */


/* End of File */





















